<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="import" href=".html">
    <title>Document</title>
    <style>
        p{
            width:300px;
            height:300px;
            background: red;
        }
        .fade-enter-active,.fade-leave-active{
            transform: 1s all ease;
        }
        .fade-enter-active{
            opacity:1;
            width:300px;
            height:300px;
        }
        .fade-leave-active{
            opacity:0;
            width:100px;
            height:100px;
        }
        .fade-enter,.fade-leave{
            opacity:0;
            width:100px;
            height:100px;
        }
    </style>
</head>
<body>
    <div id="box">
        <input type="button" value="单击显示隐藏" @click="show=!show">
        <transition name="fade"
            @before-enter="beforeEnter"
            @enter="enter"
            @after-enter="afterEnter"

            @before-leave="beforeLeave"
            @leave="leave" 
            @after-leave="afterLeave">

        <p v-show="show"></p>

</transition>
    </div>
    <script src="/JS文件/vue.js"></script>
    <script>
        window.onload=function(){
            new Vue({
                el:'#box',
                data:{
                    show:false
                },
                methods:{
                    beforeEnter(el){
                        console.log('动画enter之前');
                    },
                    enter(el){
                        console.log('动画enter');
                    },
                    afterEnter(el){
                        console.log('动画进入完成之后');
                    },
                    beforeLeave(el){
                        console.log('动画leave之前');
                    },
                    leave(el){
                        console.log('动画enter');
                    },
                    afterLeave(el){
                        console.log('动画离开完成之后');
                    }
                }

            })
        };
    </script>
</body>
</html>